<h2><?=tr('News administration')?></h2>
<p class="backpage">&raquo; <?=fgsBase::linkPage(tr('Add a news'), 'admin_news', array('add'))?></p>
<?php

	if (!is_null($form)) {

		echo $form->output();
		
	} else {

		$cats = fgsNews::getCategories();
		$news = fgsNews::getLast(null, null, null, false);

		if (!$news)
			echo tr('No news yet');
		else {
			$tbl = new htmlTable();

			$tbl->setHeader('action', array(
				'width' => '50px',
			));
			$tbl->setHeader('id', array(
				'title' => tr('Id'),
				'width' => '5ex',
			));
			$tbl->setHeader('lang', array(
				'title' => tr('Lang'),
				'width' => '10ex',
			));
			$tbl->setHeader('date', array(
				'title' => tr('Date'),
				'width' => '24ex',
			));
			$tbl->setHeader('title', array(
				'title' => tr('Title'),
			));

			foreach ($news as $n) {
				$tbl->set('id', $n['id']);
				$tbl->set('title', $n['title']);
				$tbl->set('cat', $cat[$n['category']]);
				$tbl->set('lang', $n['lang']);
				$tbl->set('date', fgsUtils::formatDate($n['date']));

				$actions = array();
				if (!$n['is_online']) {
					$actions[] = fgsBase::linkPage(fgsBase::image('ok'), 'admin_news', array('show', $n['id']));
					$tbl->setLineParam('class', 'disabled');
				} else {
					$actions[] = fgsBase::linkPage(fgsBase::image('del'), 'admin_news', array('hide', $n['id']));
				}
				$actions[] = fgsBase::linkPage(fgsBase::image('edit'), 'admin_news', array('edit', $n['id']));

				$tbl->set('action', implode(' ', $actions));
					
				$tbl->push();
			}

			echo $tbl->render();
		}	

	}
	
?>
